package com.zksk.admin.mapper.customer;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zksk.mbg.admin.domain.Agreement;
import com.zksk.mbg.admin.domain.RAgreementCustomerReq;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 客户（平台）提供给用户得保函模板 Mapper 接口
 * </p>
 *
 * @author Zksk Acmen
 * @since 2022-12-07
 */
@Mapper
public interface RAgreementCustomerReqDao extends BaseMapper<RAgreementCustomerReq> {

    @Select("SELECT\n" +
            "\ta.id,\n" +
            "\ta.agreement_type,\n" +
            "\ta.temp_name,\n" +
            "\ta.temp_file_path,\n" +
            "\ta.file_name,\n" +
            "\ta.sign_info,\n" +
            "\ta.ref_prod_enum_id,\n" +
            "\ta.ref_prod_type\n" +
            "FROM\n" +
            "\tplatform_agreement AS a\n" +
            "\tINNER JOIN \n" +
            "\t(\n" +
            "\t\tSELECT\n" +
            "\t\t\tagreement_id \n" +
            "\t\tFROM\n" +
            "\t\t\tplatform_r_agreement_customer_req \n" +
            "\t\tWHERE\n" +
            "\t\t\tcustomer_prod_req_id = #{id}\n" +
            "\t) AS i\n" +
            "WHERE\n" +
            "\ta.id = i.agreement_id\n" +
            "AND\n" +
            "\ta.del_flag = 0")
    List<Agreement> selectAgreementList(@Param("id") Long id);

}
